using Moq;
using NUnit.Framework;
using Tycho.Parser.Syntax;

namespace Tycho.Parser.Tests.Syntax {
    [TestFixture]
    public class MultipleSyntaxSpecification {
        [Test]
        public void AccumulateCapturesShouldAddCapturesAsMultiples() {
            var accumulator = new CaptureAccumulator ();

            string captureName = "name";
            var syntax = new MultipleSyntax (0, -1, new CaptureSyntax (captureName, null));

            syntax.AccumulateCaptures (accumulator);

            Assert.AreEqual (true, accumulator.Captures[captureName]);
        }

        [Test]
        public void CompileShouldSetIsFirstToTrueIfItWasInitiallyTrueWhenMinimumIsZero () {
            var multiple = new MultipleSyntax (0, -1, new FakeSetIsFirstSyntax (false));

            var productionLookup = new ProductionLookup (null, null, null);
            Assert.IsTrue (productionLookup.IsFirst);
            multiple.Compile (productionLookup);
            Assert.IsTrue (productionLookup.IsFirst);
        }

        [Test]
        public void CompileShouldSetIsFirstToFalseIfItWasInitiallyFalseWhenMinimumIsZero () {
            var multiple = new MultipleSyntax (0, -1, new FakeSetIsFirstSyntax (false));

            var productionLookup = new ProductionLookup (null, null, null);
            productionLookup.IsFirst = false;
            multiple.Compile (productionLookup);
            Assert.IsFalse (productionLookup.IsFirst);
        }
    }
}